package org.awenlice.playerdailyshop.network;

import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.network.simple.SimpleChannel;
import org.awenlice.playerdailyshop.PlayerDailyShop;

public class PacketHandler {
    private static final String PROTOCOL_VERSION = "1";
    private static final String PROTOCOL_VERSION2 = "1";

    public static final SimpleChannel INSTANCE1 = NetworkRegistry.newSimpleChannel(
            new ResourceLocation(PlayerDailyShop.MODID, "sell"),
            () -> PROTOCOL_VERSION,
            PROTOCOL_VERSION::equals,
            PROTOCOL_VERSION::equals
    );

    public static final SimpleChannel INSTANCE2 = NetworkRegistry.newSimpleChannel(
            new ResourceLocation(PlayerDailyShop.MODID, "buy"),
            () -> PROTOCOL_VERSION2,
            PROTOCOL_VERSION2::equals,
            PROTOCOL_VERSION2::equals
    );

    public static void register() {
        int id = 0;
        INSTANCE1.registerMessage(id++, OpenSellShopPacket.class, OpenSellShopPacket::encode, OpenSellShopPacket::new, OpenSellShopPacket::handle);
        INSTANCE2.registerMessage(id++, OpenBuyShopPacket.class, OpenBuyShopPacket::encode, OpenBuyShopPacket::new, OpenBuyShopPacket::handle);
    }

}